﻿using System;

/// <summary>
/// original code: http://www.dotnetperls.com/enum-flags
/// </summary>
class Program
{
    [Flags]
    enum RenderType
    {
        None = 0x0,
        DataUri = 0x1,
        GZip = 0x2,
        ContentPage = 0x4,
        ViewPage = 0x8,
        HomePage = 0x10 // Next two values could be 0x20, 0x40
    }

    static void Main()
    {
        // 1.
        // Set the first type.
        RenderType type1 = RenderType.ContentPage;

        // 2.
        // Set the second type if the condition matches.
        if (true)
        {
            type1 |= RenderType.GZip;
        }

        // 3.
        // Check the enum flags.
        Check(type1);

        // 4.
        // Set a new enum in three statements.
        RenderType type2 = RenderType.ViewPage;
        type2 |= RenderType.DataUri;
        type2 |= RenderType.GZip;

        // 5.
        // See if the enum contains this flag.
        if ((type2 & RenderType.DataUri) == RenderType.DataUri)
        {
            Console.WriteLine("True");
        }

        // 6.
        // See if the enum contains this flag.
        if ((type2 & RenderType.ContentPage) == RenderType.ContentPage)
        {
            throw new Exception();
        }

        // 7.
        // Check the enum flags.
        Check(type2);

        Console.ReadLine();
    }

    static void Check(RenderType type)
    {
        Console.WriteLine(type.ToString().ToLower());
    }
}